@import "@/app/styles";

$transition: 150ms;

.InputField {
  $this: &;
  position: relative;
  margin-bottom: 40px;
  height: 56px;
  width: 100%;
  word-wrap: break-word;

  &-Label {
    position: absolute;
    top: 20px;
    left: 12px;
    z-index: 1;
    color: $color-lighting;
    pointer-events: none;
    transition: all $transition;

    #{$this}-Inner__error {
      background-color: $color-darkness;
    }

    &Required {
      color: $color-red;
    }
  }

  &-Inner {
    width: 100%;
  }

  & input:-webkit-autofill.Input__active,
  & input:-webkit-autofill.Input__active:hover,
  & input:-webkit-autofill.Input__active:focus,
  & input:-webkit-autofill.Input__active:active {
    -webkit-box-shadow: 0 0 0 30px $color-darkness inset !important;
  }

  & input:-webkit-autofill {
    -webkit-text-fill-color: $color-white !important;
  }

  & textarea,
  & textarea:hover {
    background-color: $color-darkness;
  }

  &__active {
    width: 100%;

    #{$this}-Label {
      top: 0;
      padding: 0;
      color: $color-lighting;
    }
  }

  &__disabled {
    cursor: default;
    width: 100%;

    #{$this}-Label {
      top: 0;
      padding: 0;
      color: $color-lighting;
    }
  }

  /* -------------------- Fix autocomplete form -------------------- */
  input:-webkit-autofill {
    -webkit-text-fill-color: $color-white;
  }

  #{$this}-Inner:-webkit-autofill {
    -webkit-background-clip: $color-white;
  }

  #{$this}-Inner {
    &:-webkit-autofill {
      border: 1px solid rgba(0, 0, 0, 0.54);

      & ~ #{$this}-Label {
        top: 0;
        padding: 0;
        color: $color-white;
        background-color: $color-darkness;
      }
    }
  }

  &-ErrorField {
    display: block;
    padding-top: 5px;
    color: $color-red;
    transition: all 0.3s;
  }
}

.Input {
  $this: &;
  display: flex;
  align-items: center;
  padding: 18px 40px 18px 12px;
  width: 100%;
  background-color: $color-darkness;
  border: 1px solid $color-darkness;
  border-radius: $border-radius;
  outline: transparent;
  color: $color-white;
  caret-color: $color-white;

  &:hover {
    background-color: $color-gray;
    transition: background-color 0.25s ease;
  }

  &#{$this}__active {
    border: 1px solid $color-primary;
  }

  &__disabled {
    border: 1px solid $color-lighting;
    color: $color-white;

    &:hover {
      background-color: $color-darkness;
    }
  }

  &#{$this}__error {
    background-color: $color-darkness;
    border: 1px solid $color-red;

    &:hover {
      background-color: $color-darkness;
      transition: background-color 0.25s ease;
    }
  }
}
